<template>
  <van-address-edit
    :area-list="areaList"
    show-postal
    show-set-default
    show-search-result
    :search-result="searchResult"
    :area-columns-placeholder="['请选择', '请选择', '请选择']"
    @save="onSave"
    @delete="onDelete"
    @change-detail="onChangeDetail"
  />
</template>

<script>
import Vue from 'vue'
import { AddressEdit, Toast } from 'vant'

Vue.use(AddressEdit)
Vue.use(Toast)

export default {
  data () {
    return {
      areaList: {
        province_list: {
          110000: '北京市',
          310000: '上海市'
        },
        city_list: {
          110100: '',
          310100: ''
        },
        county_list: {
          110101: '东城区',
          110102: '西城区',
          110105: '朝阳区',
          110106: '丰台区',
          110107: '石景山区',
          110108: '海淀区',
          110109: '门头沟区',
          110111: '房山区',
          110112: '通州区',
          110113: '顺义区',
          110114: '昌平区',
          110115: '大兴区',
          110116: '怀柔区',
          110117: '平谷区',
          110118: '密云区',
          110119: '延庆区',
          310101: '黄浦区',
          310104: '徐汇区',
          310105: '长宁区',
          310106: '静安区',
          310107: '普陀区',
          310109: '虹口区',
          310110: '杨浦区',
          310112: '闵行区',
          310113: '宝山区',
          310114: '嘉定区',
          310115: '浦东新区',
          310116: '金山区',
          310117: '松江区',
          310118: '青浦区',
          310120: '奉贤区',
          310151: '崇明区'
        }
      },
      searchResult: []
    }
  },
  methods: {
    onSave () {
      Toast('修改成功')
      this.$router.push('./address')
    },
    onDelete () {
      Toast('delete')
    },
    onChangeDetail (val) {
      // if (val) {
      //   this.searchResult = [
      //     {
      //       name: '黄龙万科中心',
      //       address: '杭州市西湖区'
      //     }
      //   ]
      // } else {
      //   this.searchResult = []
      // }
    }
  }
}
</script>

<style>
</style>
